const {resolve} = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: {
        vendor: ['./src/js/common.js', './src/js/jquery.js'],
        index: './src/js/index.js',
        cart: './src/js/cart.js'
    },

    output: {
        filename: "[name].js",
        path: resolve(__dirname, 'build')
    },

    //打包非js文件以外的资源
    module: {
        rules: []
    },

    plugins: [
        new HtmlWebpackPlugin({
            template: "./src/index.html",
            filename: "index.html",
            chunks: ["index", "vendor"]
        }),
        new HtmlWebpackPlugin({
            template: "./src/cart.html",
            filename: "cart.html",
            chunks: ["cart", "vendor"]
        })
    ],

    mode: "development"
};